package fr.emse.tatiana.importexport;





import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;



public class ImportCorpusMainPage extends WizardPage implements Listener{



	// widgets on this page 
	Text travelDate;
	Combo travelMonth;
	Combo travelYear;
	Combo returnDate;
	Combo returnMonth;
	Combo returnYear;	
	Button priceButton;	
	Text fromText;
	Text toText;
	Button planeButton;
	Button carButton;


	private Text fileName;
	private String path;


	/**
	 * 
	 */
	public ImportCorpusMainPage() {
		super("page1");
		setTitle("Import Corpus");
		setDescription("Choose a corpus to import");


	}

	public void createControl(Composite parent) {
		GridData gd;
		Composite composite =  new Composite(parent, SWT.NULL);
		GridLayout gl = new GridLayout();
		int ncol = 3;
		gl.numColumns = ncol;
		composite.setLayout(gl);
		new Label (composite, SWT.NONE).setText("File name:");						
		fileName = new Text(composite, SWT.BORDER);
		gd= new GridData(GridData.FILL_HORIZONTAL);
		gd.grabExcessHorizontalSpace = true;
		fileName.setLayoutData(gd);
		Button browseButton = new Button(composite, SWT.PUSH);
		browseButton.setText("Browse");
		browseButton.setLayoutData(new GridData(
				GridData.HORIZONTAL_ALIGN_FILL));
		browseButton.addListener(SWT.Selection, this);	
		setControl(composite);		
	}



	public void handleEvent(Event event) {
		FileDialog dialog = new FileDialog(getContainer().getShell(), SWT.OPEN); 
		String[] exts = {"*.zip"};
		dialog.setFilterExtensions(exts);
		path = dialog.open();	
		fileName.setText(path);
		getWizard().getContainer().updateButtons();
		((ImportCorpusWizard) getWizard()).setPath(path);
		
	}


}


